package config

import (
	"gitee.com/xiaofangjian/dadi/rdb"
	"gitee.com/xiaofangjian/dadi/rds"
	"github.com/BurntSushi/toml"
)

type ConfigFile struct {
	App      App
	Database map[string]rdb.Config
	Redis    map[string]rds.Config
}

type App struct {
	Secret string
}

var appConfig ConfigFile
var appConfigMap map[string]any

func InitContent(content []byte) {
	_, err := toml.Decode(string(content), &appConfig)
	if err != nil {
		panic(err)
	}

	_, err = toml.Decode(string(content), &appConfigMap)
	if err != nil {
		panic(err)
	}

	return
}

func Config() ConfigFile {
	return appConfig
}

func ConfigMap() map[string]interface{} {
	return appConfigMap
}
